﻿@using ZBJF.Warranty.Common.Enums
@using ZBJF.Warranty.WebProvider
@{
    ViewBag.Title = "清洗产品管理";
}
<div class="breadcrumbs" id="breadcrumbs">
    <ul class="nav nav-tabs">
        <li class="active"><a href="/Cleaning/CleaningProduct/CleaningProductIndex">清洗产品列表</a></li>
        <li class="Add-R"><a href="/Cleaning/CleaningProduct/CleaningProductEdit/0">添加清洗产品</a></li>
    </ul>
</div>
<form id="searchForm" class="breadcrumb form-search">
    <div>
        <label>清洗产品名称</label>
        @Html.TextBox("CleaningProductName", "", new { placeholder = "请输入清洗产品名称" })
        <input id="btnReset" class="btn Search-R form-reset" type="button" value="重置">
        <input id="btnSubmit" class="btn btn-primary Search-R" type="button" value="查询" onclick="search();">
    </div>
</form>
<table id="CleaningProductTable" class="table table-striped table-bordered table-hover">
    <thead>
        <tr>
            <th width="50">序号</th>
            <th width="150">清洗产品名称</th>
            <th width="80">单价</th>
            <th width="200">单位说明</th>
            <th width="300">产品描述</th>
            <th width="80">是否启用</th>
            <th width="80">最后修改人</th>
            <th width="150">最后修改时间</th>
            <th width="80">操作</th>
        </tr>
    </thead>
</table>
@section scripts{
    @Scripts.Render("~/bundles/chosen")
    @Styles.Render("~/Content/chosen")
    @Scripts.Render("~/bundles/datatable")
    @Styles.Render("~/Content/datatable")
<script src="~/Scripts/moment.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#RoleListID").chosen();
            var objTable = $("#CleaningProductTable").dataTable({
                fnDrawCallback: function () {
                    ControlPermissionOperate();
                },
                "sAjaxSource": "/Cleaning/CleaningProduct/CleaningProductList",
                "aaSorting": [[7, "desc"]],
                aoColumns: [
                    {
                        "mData": null,
                        "bSortable": false,
                        "fnRender": function (nRow) {
                            return nRow.iDataRow + 1;
                        }
                    },
                    { "mData": "ProductName", "bSortable": false },
                    { "mData": "Price" },
                    { "mData": "UnitInstruction", "bSortable": false },
                    { "mData": "ProductDescribe", "bSortable": false ,"class":"myclass"},
                    {
                        "mData": null,
                        fnRender: function (nRow) {
                            return nRow.aData.IsAvailable ? bootStrapOkIncon : bootStrapRemoveIncon;
                        }
                    },
                    { "mData": "LastModifyBy", "bSortable": false },
                    {
                        "mData": null,
                        fnRender: function(nRow) {
                            return moment(nRow.aData.LastModifyTime).format('YYYY-MM-DD HH:mm:ss');
                        }
                    },
                    {
                        "mData": null,
                        "bSortable": false,
                        fnRender: function (nRow) {
                            var html = "<a class='Edit-R' href='/Cleaning/CleaningProduct/CleaningProductEdit/" + nRow.aData.ID + "' title='edit'><i class='icon-edit'></i></a>";
                            html += "<a class=\"green Edit-R\" href=\"javascript:UpdateStatus('" + nRow.aData.ID + "'," + !nRow.aData.IsAvailable + ",'/Cleaning/CleaningProduct/UpdateStatus','CleaningProductTable')\" title=\"" + (nRow.aData.IsAvailable ? "禁用" : "启用") + "\">" + (nRow.aData.IsAvailable ? bootStrapRemoveIncon : bootStrapOkIncon) + "</a>";
                            return html;
                        }
                    }
                ]
            });
        });

        function search() {
            /*给查询对象赋值*/
            queryParamList.CleaningProductName = String($("#CleaningProductName").val());
            $("#CleaningProductTable").dataTable().fnDraw();
        }

    </script>
}
